package com.ejd.web.vo.genl;

import java.util.List;




import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;


import com.ejd.service.IClothingStyleService;
import com.ejd.service.IShoesStyleService;
import com.ejd.utils.MessageFactory;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.ClothingStyle;
import com.ejd.web.bo.impl.ShoesStyle;
import com.ejd.web.constant.EjdConstants;
import com.ejd.web.constant.SpringBeanConstants;

@ManagedBean(name="existClothingStyle")
@SessionScoped
public class ExistClothingStyleBean implements java.io.Serializable {

	private SelectItem[] clothingStyleItems;

	
	public SelectItem[] getClothingStyleItems() {
		return clothingStyleItems;
	}


	public void setClothingStyleItems(SelectItem[] clothingStyleItems) {
		this.clothingStyleItems = clothingStyleItems;
	}


	public ExistClothingStyleBean() {
		
		IClothingStyleService<ClothingStyle,Long> clothingStyleService = (IClothingStyleService<ClothingStyle,Long>)SpringFacesUtil.getSpringBean(SpringBeanConstants.CLOTHING_STYLE_SERVICE_BEAN_NAME);
		clothingStyleService.setEntityClass(ClothingStyle.class);
		clothingStyleService.setPKClass(Long.class);
		List<ClothingStyle> clothingStyles = clothingStyleService.getAll();
		SelectItem[] tempClothingStyleItems = new SelectItem[clothingStyles.size()];
		if (null != clothingStyles && !(clothingStyles.isEmpty())) {
			for (int i=0; i< tempClothingStyleItems.length; i++) {
				ClothingStyle clothingStyle = (ClothingStyle) clothingStyles.get(i);
				String clothingStyleNameN18 = MessageFactory.getMessage(EjdConstants.USER_BUNDLE_NAME,clothingStyle.getStyleName(), FacesMessage.SEVERITY_ERROR).getDetail();
				tempClothingStyleItems[i] = new SelectItem(clothingStyle.getStyleCode(),clothingStyleNameN18);
			}
		}
		this.setClothingStyleItems(tempClothingStyleItems);
	}
}
